All Questions
47 questions
1vote
2answers
213views
Redirect to a filename that will be a variable and contain a command substitution
I'm using nmap to scan a network and then create an XML file that contains the scanned information. I want that XML file to contain the date of the scan so that each file is unique and I can see the ...
-1votes
1answer
113views
Bash script via .desktop save to variable external filename with fullpath
ok i try to make the most resumed the points i want to do. Sorry for the repetions i don't know how make this question more objectively The first i am making a script for launch "mupen64plus"...
0votes
2answers
207views
move recently created files matching a pattern from one folder to a different one
I am looking for a bash script example which does the following: I have files being written under /tmp folder I do at the xterm prompt, ls -ltr which gives me a list of recent files such as: ...
1vote
2answers
357views
ranger chain commands in config
I am using ranger as my terminal file manager and now that I understand the basics, I wanted to get a bit deeper into customizing the rc for my purposes. One thing I like to do is to map a command to ...
0votes
1answer
836views
Only perform sed operations on lines starting with a particular string [closed]
I have the following file format Received from +11231231234 at 2021-10-10T19:56:50-07:00: This is a message that contains words like from, at, etc. Sent to +11231231234 at 2021-10-11T06:50:57+00:00: ...
0votes
2answers
1kviews
I want to count empty and non empty files in a directory with use of loop, without using find command
#!/bin/bash for i in manu; do if [ -f $i ] && [ -s $i ]; then echo " $(ls $i | wc -l) non-empty files" elif [ -f $i ] && [ ! -s $i ]; then echo " $(ls $i | ...
1vote
2answers
742views
How to store .txt file data in different columns of a CSV file using BASH?
I have a .txt file with the following data structure: Scan Times: 33.3 seconds 77.4 seconds 33.3 seconds 77.4 seconds Check Times: 110.30 seconds 72.99 seconds 72.16 seconds 110.30 seconds ...
0votes
1answer
249views
Reading newly created .txt file via bash script
I'm a beginner in bash scripting, and what I'm trying to is to build a script that is doing an API call to my enterprise system and returns the result to TXT file. In the end, I would like to read the ...
1vote
2answers
2kviews
Ext4 and Linux - very large number of files in one directory - operations
I have a problem with a very large number of files in one directory. The file system is ext4. I reached the 2**32 file limit and couldn't even write any file on this partition. The problem is very big....
1vote
1answer
382views
How to rename nested folders?
So I have a bunch of folders in the format of: .../course/year/... and I often reorganize them so that the format then changes to this: .../year/course/.... I've been meaning to learn how to write ...
0votes
0answers
66views
Execute a while loop in bash constructed from variables
I am trying to write a shell script which reads a file line by line, does some operations on each line, and write output to a new file. The file name is passed as an argument. Since the file is ...
0votes
3answers
1kviews
Comparing 2 base filenames in separate directories in bash script
I am trying to write a bash script that takes 2 file directories as arguments. It then loops through all the files in the first directory to see if there is a corresponding file in the second ...
0votes
1answer
2kviews
Script with zip command doesn't work with wildcards
I created a bash shell script to zip all files that match a pattern as follows: #!/bin/bash zip $1 $2 When I run the above script using ./myScript.sh myzip test*, only one file that starts with the ...
2votes
1answer
10kviews
Shell script to Unzip files to folders in destination with same name minus the .zip, also move every none zip to same location
I definitely need to practice my scripting... So far I have the script below which works when one .zip and one flat file are put into the source location. If multiple files are put in it does not ...
0votes
2answers
251views
Finding a file by alphabetical order
Using bash, I need to be able to find a file in a specific position when listed alphabetically. For example, if I had the files a, b, c, d, e in a directory, and I wanted to find the third file, I ...